package com.example.myapplication.moudule.mvvm;

import com.example.myapplication.ResourceTable;
import com.example.myapplication.base.mvvm.ui.BaseViewModelAbilitySlice;
import com.example.myapplication.moudule.home.repository.response.HomePageData;
import com.harmonyos.livedata.Observer;
import ohos.agp.components.Text;

public class TestViewModelAbilitySlice extends BaseViewModelAbilitySlice<TestViewModel> {
    @Override
    public int getUIContent() {
        return ResourceTable.Layout_ability_test_view_model;
    }

    private Text text_helloworld;
    @Override
    public void initComponent() {
        text_helloworld=findComponentById(ResourceTable.Id_text_helloworld);
    }

    @Override
    public void getData() {
        super.getData();
        mViewModel.getHomeData();
    }

    @Override
    public void initViewObservable() {
        super.initViewObservable();
        mViewModel.homePageDataLiveData.observe(this, new Observer<HomePageData>() {
            @Override
            public void onChanged(HomePageData homePageData) {
                text_helloworld.setText(homePageData.list.get(0).title);
            }
        });
    }

    @Override
    protected Class<TestViewModel> getViewModelClass() {
        return TestViewModel.class;
    }


}
